/*请求url*/
var urlData = require("../../../../data/url.js");
//获取应用实例
const app = getApp()
// var theArr = {
//   list1: [{
//     course_name: 'math',
//     course_start_hour:'e0000',
//     course_end_hour: 'h0000',
//   }, {
//     course_name: 'math',
//     course_start_hour: 'e000000000000000000',
//     course_end_hour: 'h0000',
//   }],
//   list2: [{
//     course_name: 'math',
//     course_start_hour: 'e0000',
//     course_end_hour: 'h0000',
//   }],
//   list3: [{
//     course_name: 'math',
//     course_start_hour: 'e0000',
//     course_end_hour: 'h0000',
//   }, {
//     course_name: 'math',
//     course_start_hour: 'e0000',
//     course_end_hour: 'h0000',
//     }, {
//       course_name: 'math',
//       course_start_hour: 'e0000',
//       course_end_hour: 'h0000',
//     }],
 
// };
var oo=[];

Page({
  data: {
    // arr: theArr,
    arr:"",
    arrr:[1,2,3,4,5,6,7,8],
    userId:1,
    role:6,
    thisurl: urlData.urlList.teachingManage.classSchedule.url,
   
  },
  onLoad: function (e) {
    console.log(this.data.arr);
    var ee = this.data.arr.list1;
    var dd= this.data.arr.list2;
    var zz = this.data.arr.list3;
    var aa=[ee.length,dd.length,zz.length];
    var ans = aa[0];
    for (var i = 1; i < 3; i++) {
      ans = aa[i] > ans ? aa[i] : ans;
    }
    console.log(ans);
    var pp = [];
    for(var w=0;w<ans;w++){
      pp[w]=1;
    }
    this.setData({//?
      arrr: pp,
    }); 
    console.log(this.data.arrr);

    // 读取login缓存
    // wx.getStorage({
    //   key: "loginConf",
    //   success: function (res) {
    //     that.setData({
    //       userId: e.currentTarget.dataset.userId,
    //       role: e.currentTarget.dataset.role
    //     });
    //   }
    // });
    var that = this;
    wx.request({
      url:this.data.thisurl,
      // url: 'http://192.168.1.110:8000/classTimetable/queryTimeTable/',
      method: "get",
      data: {
        user_id: this.data.userId,
        role: this.data.role
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        if (res.data.code == 0) {
          that.listData(e, res);
          // console.log(res.data.list1[0].course_name);
          
        }
      },
      fail: function (res) {
        console.log('刷list数据失败');
      }
    })
  },

  /*刷新数据*/
  listData: function (e, res) {
   this.setData({//?
      arr: res.data,
    });    
    console.log(this.data.arr);
    var a = this.data.arr.list1;
    var b = this.data.arr.list2;
    var c = this.data.arr.list3;
    var d = this.data.arr.list4;
    var e = this.data.arr.list5;
    var f = this.data.arr.list6;
    var g = this.data.arr.list7;
    console.log(a.length);
    var aaa = [a.length, b.length, c.length, d.length, e.length, f.length, g.length]
  
    var ans = aaa[0];
    for (var i = 1; i < 7; i++)
    {
      ans = aaa[i] > ans ? aaa[i] : ans;
    }
    var pp = [];
    for (var w = 0; w < ans; w++) {
      pp[w] = 1;
    }
    this.setData({//?
      arrr: pp,
    });
     console.log(this.data.arrr);
  },
})
